
const {wrap: async} = require('co');
const UserModel = require('../model/UserModel')
const logger = require('../../../log')('UserService');

/**
 * 用户管理 UserService
 */

/**
 * save user info
 * @param {UserModel} user 
 */
exports.save = async(function*(user, cb) {
    UserModel.create(user, function(err, data) {
        if (err) {
            logger.error('user save err', err);
            return cb(err);
        }
        return cb(null, data);
    });
});

/**
 * 查询用户列表
 */
exports.list = async(function*(query, cb) {
    let data = yield UserModel.find(query);
    return data;
})
